home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gekkan Dennou Club 147
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan).7z
/
Gekkan Dennou Club - 2000.8 Vol. 147 (Japan) (Track 1).bin
/
games
/
ippon
/
source.lzh
/
FuncEnemy
/
searchz2.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-07-07
|
4KB
|
200 lines
/* searchz2.c 自機をサーチするザコ */
#include <xsp2lib.h>
#include "../main.h"
#include "../player.h"
#include "../enemy.h"
#include "../eshot.h"
#include "../effect.h"
#include "../psearch.h"
#include "../sound.h"
#define PALET_MAIN 0x0600
#define wabs(x) ((x) >= 0 ? (short) (x) : (short) -(x))
#define abs(x) ((x) >= 0 ? (int) (x) : (int) -(x))
enum {
TO_LEFT, TO_CENTER, TO_RIGHT
};
/* 関数プロトタイプ宣言 */
static short EnemyMoveSearchZ2 (ENEMY *);
static void EnemyFreeSearchZ2 (ENEMY *);
/* 初期化ルーチン */
void EnemyAllocSearchZ2 (ENEMY * p)
{
signed short x = SHORT_LX;
/* このザコに関してはX座標は中心からの距離で */
/* 常にプレイヤーの反対側に現れる */
if (player->x < 144) {
p->lx = (player->x + x) * 65536;
p->vx = 16384;
} else {
p->lx = (player->x - x) * 65536;
p->vx = -16384;
}
p->vy = 4 * 65536;
p->angle = 64;
p->pt = obj_searchz + ((p->angle) >> 3);
p->info = PALET_MAIN | PRIORITY_ZAKO;
p->hit_sx = 12;
p->hit_sy = 12;
p->hp = 1; /* 耐久力 */
p->damage = 0;
p->damage_mode = DAMAGE_THROUGH;
p->func_enemy_move = EnemyMoveSearchZ2;
p->func_enemy_free = EnemyFreeSearchZ2;
/* コア関連 */
p->core_info = PALET_CORE_RED | PRIORITY_ZAKO;
p->core_pt = sp_core + 1;
p->m_work = 0;
p->m_work2 = 0;
p->m_work4 = 0; /* 1回接近したか */
}
/* 移動ルーチン */
/* 返り値:非0なら消去 */
static short EnemyMoveSearchZ2 (ENEMY * p)
{
/* 速度を足して上位ワード(固定整数部)だけ取り出す */
p->x = (p->lx += p->vx) >> 16;
p->y = (p->ly += p->vy) >> 16;
switch (p->m_work) {
/* まず突っ込んでくる */
case 0:
if (p->m_work2++ > 16) {
p->m_work++;
p->m_work2 = 0;
}
break;
/* 減速 */
case 1:
p->vy -= 32768;
if (p->vy <= 32768) {
p->m_work++;
p->m_work2 = 0;
p->m_work3 = 0;
p->s_work = 0;
}
break;
/* 直線運動しつつこちらを向く */
case 2:
switch (p->m_work2++) {
case 0:
if (wabs (SHORT_LX - player->x) < 16) {
p->m_work4 = TO_CENTER;
} else {
if (SHORT_LX < player->x)
p->m_work4 = TO_RIGHT; /* 右へ進む */
else
p->m_work4 = TO_LEFT; /* 左へ進む */
}
break;
case 30:
p->m_work2 = 0;
break;
default:
switch (p->m_work4) {
case TO_CENTER:
if (p->vx < 2048)
p->vx += 2048;
else
p->vx -= 2048;
if (p->vy <= 1 * 65536)
p->vy += 2048;
if (p->angle != 64) {
if (p->angle > 64)
p->angle--;
else
p->angle++;
}
p->pt = obj_searchz + ((p->angle) >> 3);
break;
case TO_RIGHT:
#define INTERVAL2 50
#define SPEED_SHOT2 6
/* 右へ進む時 */
if (p->angle > 64 - 12)
p->angle--;
p->pt = obj_searchz + ((p->angle) >> 3);
if (p->vx < 65536)
p->vx += 4096;
if (p->s_work++ > INTERVAL2) {
p->s_work = 0;
if ((wabs (player->x - p->x) + wabs (player->y - p->y)) > 96) {
EshotAlloc (ESHOT_NRG02, p->x, p->y, SPEED_SHOT2, psearch (p->x, p->y), 0);
SoundSetSE (SE_ESHOT); /* 敵ショット音 */
}
}
break;
case TO_LEFT:
/* 左へ進む時 */
if (p->angle < 64 + 12)
p->angle++;
p->pt = obj_searchz + ((p->angle) >> 3);
if (p->vx > -65536)
p->vx -= 4096;
if (p->s_work++ > INTERVAL2) {
p->s_work = 0;
if ((wabs (player->x - p->x) + wabs (player->y - p->y)) > 96) {
EshotAlloc (ESHOT_NRG02, p->x, p->y, SPEED_SHOT2, psearch (p->x, p->y), 0);
SoundSetSE (SE_ESHOT); /* 敵ショット音 */
}
}
break;
}
break;
}
break;
default:
break;
}
/* 画面外に出たら消去 */
if ((p->m_work > 0)
&& ((SHORT_LY < -32) || (SHORT_LY > 256 + 32)
|| (SHORT_LX < -32) || (SHORT_LX > 256 + 32)))
return (-1); /* 消去 */
/* もし前回ダメージを受けたなら */
if (p->damage) {
p->damage = 0;
EffectAlloc (EFFECT_EXPLZAKO, 0, p->x, p->y); /* 爆発パターンを出現させる */
EffectAlloc (EFFECT_POINTS, points_table[p->shot_count], p->x, p->y); /* 得点を出現させる */
SoundSetSE (SE_EXPL); /* ザコ爆発音 */
return (-1);
}
xobj_set_st (p); /* 表示 */
/* コアの表示 */
p->core_x = p->x - 8;
p->core_y = p->y - 8;
xsp_set_st (&(p->core_x));
return (0);
}
/* 消去ルーチン */
static void EnemyFreeSearchZ2 (ENEMY * p)
{
}